//
//  CTDialTableViewCell.m
//  CT
//
//  Created by liufanwei on 15/3/13.
//  Copyright (c) 2015年 liufanwei. All rights reserved.
//

#import "CTDialTableViewCell.h"
#import "CommonMicro.h"
#import "UILabel+WBExtension.h"
#import "UIView+WBExtension.h"

@interface CTDialTableViewCell(){
    UIImageView * imageview;
}

@end


@implementation CTDialTableViewCell
@synthesize Name;
@synthesize Phone;
@synthesize Date;
@synthesize Address;
@synthesize Line;
@synthesize Head;



-(void)awakeFromNib{
    [self setSelectionStyle:UITableViewCellSelectionStyleNone];
    Name.textColor = [UIColor blackColor];
    Phone.textColor = kRGBA16(0x666666, 0.6);
    Address.textColor = kRGBA16(0x666666, 0.6);
    Line.backgroundColor = kRGB16(0x5DCDFA);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

-(void)setdata:(CTContactShowItem *)item{
    if (item.Name.length == 0) {
        Name.text = item.PhoneNumber;
    }else{
        Name.text = item.Name;
    }
    Phone.text = item.PhoneNumber;
    Address.text = item.Addr;
    if (item.ImageData) {
        [Head setImage:[[UIImage alloc] initWithData:item.ImageData]];
        NSLog(@"这个人有头像:%@",item.Name);
    }
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"MM-dd HH:mm"];
    if (item.Date) {
        Date.text = [formatter stringFromDate:item.Date];
    }else{
        Date.text = @"";
    }
    if (item.ImageData) {
        [Head setImage:[[UIImage alloc] initWithData:item.ImageData]];
    }else{
        [Head setImage:[UIImage imageNamed:@"default_head"]];
    }
    [self setNeedsUpdateConstraints];
    [self setNeedsLayout];
}

@end
